//
//  UIBarButtonItem + Extension.swift
//  sinaWeibo7110
//
//  Created by 安静清晨 on 2017/1/5.
//  Copyright © 2017年 walk-in-minds. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    convenience init(title: String, imageName: String,target: Any?, action: Selector?) {
        
        
        let btn = UIButton()
        btn.setImage(UIImage(named:imageName), for: .normal)
        btn.setImage(UIImage(named:imageName + "_highlighted"), for: .highlighted)
        btn.setTitle(title, for: .normal)
        btn.setTitleColor(UIColor.darkGray, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        
        btn.sizeToFit()
        
        
        if let ac = action {
            btn.addTarget(target, action: ac, for: .touchUpInside)
        }
        
        self.init()
        self.customView = btn
        
    }
    
    
    
    
    
}



